<template>
	<view class="drop-down-filter-box">
		<view class="filter-select-modal resource-type" :class="{ active: show }">
			<view class="filter-select-content">
				<view class="content">
					<slot></slot>
				</view>
				<view class="modal-bottom">
					<view class="left-reset" @click="reset">重置</view>
					<button class="right-btn" @click="search">确定</button>
				</view>
			</view>
		</view>
		<view class="mask" v-if="show" @click="close"></view>
	</view>
</template>

<script>
	export default {
		props: {
			visible: {
				type: Boolean,
				default: false
			}
		},
		data() {
			return {
				show: false
			}
		},
		mounted() {
			this.show = this.visible
		},
		watch: {
			visible(val) {
				this.show = val
			}
		},
		methods: {
			reset(){
				this.$emit('reset')
			},
			
			search(){
				this.$emit('search')
			},
			
			close(){
				this.$emit('close')
			}
		}
	}
</script>

<style lang="scss">
	.drop-down-filter-box{
		.filter-select-modal{
			position: absolute;
			top: 0;
			left: 0;
			z-index: 101;
			width: 100vw;
			background: #fff;
			border-bottom-left-radius: 16rpx;
			border-bottom-right-radius: 16rpx;
			max-height: 0;
			box-sizing: border-box;
			overflow: hidden;
			opacity: 0;
			transition: all .3s;
			
			&.active{
				max-height: 60vh;
				top: 92%;
				opacity: 1;
				overflow: initial;
			}
			
			.filter-select-content{
				padding: 32rpx 30rpx;
				overflow: inherit;
			}
			
			.modal-bottom{
				display: flex;
				line-height: 80rpx;
				margin-top: 24rpx;
				
				.left-reset{
					&::before{
						content: '';
						display: inline-block;
						width: 32rpx;
						height: 32rpx;
						background: url('../static/reset.png') center no-repeat;
						background-size: 32rpx 32rpx;
						vertical-align: middle;
						margin-top: -4rpx;
						margin-right: 10rpx;
					}
				}
				
				.right-btn{
					flex: 1;
					height: 80rpx;
					line-height: 80rpx;
					background: #59E1CE;
					border-radius: 8rpx;
					color: #fff;
					font-size: 28rpx;
					margin-left: 48rpx;
					border: none;
				}
			}
			
		}
		.mask{
			position: fixed;
			bottom: 0;
			left: 0;
			z-index: 100;
			width: 100%;
			height: calc(100% - 330rpx);
			background: rgba(0, 0, 0, 0.5);
		}
	}
</style>